package com.example.figurehecheng.controller.user;


import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.vo.NewsVO;
import com.example.figurehecheng.domain.vo.SceneryDetailVO;
import com.example.figurehecheng.domain.vo.VenuesVO;
import com.example.figurehecheng.service.IVenuesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 场馆信息表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-04
 */
@RestController("userVenuesController")
@RequestMapping("/user/venues")
@Api(tags = "用户端-场馆相关接口")
@CrossOrigin
@Slf4j
public class VenuesController {
    @Autowired
    private IVenuesService venuesService;
    /**
     * 获取场馆列表
     */
    @GetMapping("/list")
    @ApiOperation("获取场馆列表")
    public Result<List<VenuesVO>> getVenuesList() {
        List<VenuesVO> venuesList = venuesService.getVenuesList();
        log.info(String.valueOf(venuesList));
        return Result.success(venuesList);
    }
    /**
     * 查询场馆详情
     * @return
     */
    @GetMapping("/detail/{id}")
    @ApiOperation("查询场馆详情")
    public Result<VenuesVO> getNewsDetail(@PathVariable("id") Long id){
        VenuesVO newsVO = venuesService.getVenuesVODetail(id);
        log.info(String.valueOf(newsVO));
        return Result.success(newsVO);
    }

    /**
     * 根据名称搜索场馆
     * @param name 场馆名称
     * @return 场馆列表
     */
    @GetMapping("/searchByName")
    @ApiOperation("根据名称搜索场馆")
    public Result<List<VenuesVO>> searchVenuesByName(@RequestParam("name") String name) {
        System.out.println("name:"+name);
        List<VenuesVO> venuesList = venuesService.searchVenuesByName(name);
        return Result.success(venuesList);
    }
}
